import Vue from 'vue'
import App from './App.vue'
import router from './router'
import axios from 'axios'
// import fastClick from 'fastclick'
import store from './store/index.js'
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/'
axios.defaults.header = { 'Access-Control-Allow-Origin': '*' }

// fastClick.attach(document.body)
// Vue.use(VueAwesomeSwiper)
Vue.config.productionTip = false
Vue.prototype.$http = axios
Vue.filter('pattern', function (date, format) {
  if (typeof date === 'string') {
    var mts = date.match(/(\/Date\((\d+)\)\/)/)
    if (mts && mts.length >= 3) {
      date = parseInt(mts[2])
    }
  }
  date = new Date(date)
  if (!date || date.toUTCString() === 'Invalid Date') {
    return ''
  }
  var map = {
    M: date.getMonth() + 1,
    d: date.getDate(),
    h: date.getHours(),
    m: date.getMinutes(),
    s: date.getSeconds(),
    q: Math.floor((date.getMonth() + 3) / 3),
    S: date.getMilliseconds()
  }
  format = format.replace(/([yMdhmsqS])+/g, function (all, t) {
    var v = map[t]
    if (v !== undefined) {
      if (all.length > 1) {
        v = '0' + v
        v = v.substr(v.length - 2)
        return v
      }
    } else if (t === 'y') {
      return (date.getFullYear() + '').substr(4 - all.length)
    }
    return all
  })
  return format
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
